package LeetCode;

/**
 * @Classname LC322
 * @Description // https://leetcode-cn.com/problems/coin-change/ 动态规划
 * @Date 2021/4/21 22:22
 * @Created by yin
 */
public class LC322 {
    // 无限背包
    public int coinChange(int[] coins, int amount) {
        int length = coins.length;
        int[][] dp = new int[length + 1][amount + 1]; // 表示数量
        for (int i = 1; i <= length; i++) {
            for (int j = 1; j <= amount; j++) {
                if(j >= coins[i-1]){
                    dp[i][j] = Math.max(dp[i-1][j-coins[i-1]] ,dp[i][j-coins[i-1]]);
                }

            }
        }
        return dp[length][amount];

    }
}
